#ifndef SERIAL_PORT_H
#define SERIAL_PORT_H

#include <Windows.h>

#define WINAPI __stdcall
#define WAIT_TIME 2000
#define MAX_DATA_LENGTH 255

class SerialPort {
  public:
    SerialPort() = default;
    explicit WINAPI SerialPort(const char *PortName);
    ~SerialPort();

    int WINAPI ReadSerialPort(const char *Buffer, unsigned int BuffSize);
    bool WINAPI WriteSerialPort(const char *Buffer, unsigned int BuffSize);
    bool WINAPI IsConnected(void);
    void WINAPI CloseSerial(void);

  private:
    HANDLE SerialHandle;
    bool Connected;
    COMSTAT Status;
    DWORD Errors;
};

#endif